<template>
  <div class="app-container">
    <h4 class="form-header h4">门店信息</h4>
    <el-table v-loading="loading" ref="table" :data="roles.slice((pageNum-1)*pageSize,pageNum*pageSize)">
      <el-table-column label="序号" type="index" align="center">
        <template slot-scope="scope">
          <span>{{(pageNum - 1) * pageSize + scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="方案编号" align="center" prop="schemePlan" />
      <el-table-column label="门店代码" align="center" prop="deptId" />
      <el-table-column label="门店名称" align="center" prop="deptName" />
    </el-table>

    <pagination v-show="total>0" :total="total" :page.sync="pageNum" :limit.sync="pageSize" />
  </div>
</template>

<script>
import { getSchemeDept } from "@/api/system/scheme";

export default {
  name: "SchemeDept",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 分页信息
      total: 0,
      pageNum: 1,
      pageSize: 10,
      // 选中角色编号
      roleIds:[],
      // 角色信息
      roles: [],
    };
  },
  created() {
    const schemeId = this.$route.params && this.$route.params.schemeId;
    if (schemeId) {
      this.loading = true;
      getSchemeDept(schemeId).then((response) => {
        this.roles = response.rows;
        this.total = this.roles.length;
        this.$nextTick(() => {
          this.roles.forEach((row) => {
            if (row.flag) {
              this.$refs.table.toggleRowSelection(row);
            }
          });
        });
        this.loading = false;
      });
    }
  },
  methods: {

  },
};
</script>
